package com.olda.play.login.service.impl;

import com.olda.play.common.service.QiNiuService;
import com.olda.play.login.service.LoginService;
import com.olda.play.login.vo.WechatUserVo;
import com.olda.play.model.UserDetailInfo;
import com.olda.play.rpc.CommonResponseDto;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.security.Principal;
import java.util.Map;

/**
 */
@Service
@RestController
public class LoginServiceImpl implements LoginService {


//    @Reference(timeout = 300000,retries = 0)
    @Reference()
    private QiNiuService qiNiuService;

    /**
     * 测试rpclogin接口
     * @param
     * @return
     */
    @ApiOperation(value = "(测试rpclogin接口)")
    @RequestMapping(value = "/testLogin",method = RequestMethod.GET,produces = "application/json;charset=UTF-8" )
    @ResponseBody
    @Override
    public CommonResponseDto<String> testLogin() {
        return qiNiuService.simpleupload();
    }

    /**
     * 根据用户名获取用户信息
     * @param username
     * @return
     */
    @ApiOperation(value = "(根据用户名获取用户信息接口)")
    @RequestMapping(value = "/getUserDetailInfoByUserName",method = RequestMethod.GET,produces = "application/json;charset=UTF-8" )
    @ResponseBody
    @Override
    public CommonResponseDto<UserDetailInfo> getUserDetailInfoByUserName(String username) {
        UserDetailInfo userDetailInfo=new UserDetailInfo();
        //查询用户信息
//        return CommonResponseDto.success(userDetailInfo);
        return null;
    }

    @ApiOperation(value = "(根据用户名获取用户信息接口)")
    @RequestMapping(value = "/postAccessToken",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    @ResponseBody
    @Override
    public Object postAccessToken(
            @ApiIgnore Principal principal,
            @ApiIgnore @RequestParam Map<String, String> parameters
    )  {
        System.out.println("-------------");

        return CommonResponseDto.success("");
    }

    @Override
    public CommonResponseDto<UserDetailInfo> loadUserByOpenId(String openid) {
        return null;
    }

    @Override
    public void addWechatUser(WechatUserVo wechatUserVo) {

    }
}
